﻿using System;
using System.Linq;

namespace BarManagement.DomainModel.Base.Extensions
{
    public static class QueryableExtensions
    {
        public static PaginatedList<T> ToPaginatedList<T>(this IQueryable<T> query, int pageIndex, int pageSize, int total)
        {            
            return new PaginatedList<T>(query.ToList(), pageIndex, pageSize, total);
        }
        public static IQueryable<T> Paginate<T>(this IQueryable<T> query, int pageIndex, int pageSize)
        {
            return query.Skip((pageIndex - 1) * pageSize).Take(pageSize);            
        }
    }
}
